package com.googlecode.allinclusive.fw.web.filter;

import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;

import javax.servlet.ServletOutputStream;

/**
 * GZIP输出流
 */
public class GZipServletOutputStream extends ServletOutputStream {
	
	/* GZIP输出流*/
	private GZIPOutputStream gzos;

	/**
	 * 构造方法
	 * @param os GZIP输出流
	 */
	public GZipServletOutputStream(OutputStream os) throws IOException {
		gzos = new GZIPOutputStream(os);
	}

	@Override
	public void flush() throws IOException {
		gzos.flush();
	}

	@Override
	public void write(byte[] b, int off, int len) throws IOException {
		gzos.write(b, off, len);
	}

	@Override
	public void write(byte[] b) throws IOException {
		gzos.write(b);
	}

	@Override
	public void write(int arg0) throws IOException {
		gzos.write(arg0);
	}

	public void finish() throws IOException {
		gzos.finish();
	}

	public void close() throws IOException {
		gzos.close();
	}
}
